/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jFOperacao.java
 *
 * Created on 13/04/2011, 00:35:23
 */

package sgfi;

import java.awt.Color;
import java.awt.Font;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.border.TitledBorder;
import sgfi.Classes.ClassConecta;
import sgfi.Classes.ComboItem;
import sgfi.Classes.Comunidade;
import sgfi.Classes.Contas;
import sgfi.Classes.Funcoes;
import sgfi.Classes.Pessoas;

/**
 *
 * @author vitiazze
 */
public class jFOperacao extends javax.swing.JDialog {


    /** Creates new form jFOperacao */
    public jFOperacao() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox5 = new javax.swing.JComboBox();
        origemjPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        contaOrigemjComboBox = new javax.swing.JComboBox();
        atualizarContaOrigjButton = new javax.swing.JButton();
        painelDestinojPanel = new javax.swing.JPanel();
        contaDestjLabel = new javax.swing.JLabel();
        contaDestinojComboBox = new javax.swing.JComboBox();
        atualizarContaDestjButton = new javax.swing.JButton();
        pessoajComboBox = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        atualizaPessoajButton = new javax.swing.JButton();
        numDocjLabel = new javax.swing.JLabel();
        tipoDocjLabel = new javax.swing.JLabel();
        tipoDocjComboBox = new javax.swing.JComboBox();
        tipoDocjButton = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        historicojTextField = new javax.swing.JTextField();
        numDocjTextField = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jFormattedTextField1 = new javax.swing.JFormattedTextField();
        dataLancjFormattedTextField = new javax.swing.JFormattedTextField();
        valorfinaljFormattedTextField = new javax.swing.JFormattedTextField();
        jPanel4 = new javax.swing.JPanel();
        sairjButton = new javax.swing.JButton();
        executarjButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        comunidadejComboBox = new javax.swing.JComboBox();
        atualizarComunidadejButton = new javax.swing.JButton();

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox5.setName("jComboBox5"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle(operacaoDesc);
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sgfi.SGFIApp.class).getContext().getResourceMap(jFOperacao.class);
        origemjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("origemjPanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, resourceMap.getColor("origemjPanel.border.titleColor"))); // NOI18N
        origemjPanel.setName("origemjPanel"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        contaOrigemjComboBox.setName("contaOrigemjComboBox"); // NOI18N

        atualizarContaOrigjButton.setIcon(resourceMap.getIcon("atualizarContaOrigjButton.icon")); // NOI18N
        atualizarContaOrigjButton.setText(resourceMap.getString("atualizarContaOrigjButton.text")); // NOI18N
        atualizarContaOrigjButton.setName("atualizarContaOrigjButton"); // NOI18N
        atualizarContaOrigjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizarContaOrigjButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout origemjPanelLayout = new javax.swing.GroupLayout(origemjPanel);
        origemjPanel.setLayout(origemjPanelLayout);
        origemjPanelLayout.setHorizontalGroup(
            origemjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(origemjPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(origemjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(origemjPanelLayout.createSequentialGroup()
                        .addComponent(contaOrigemjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(atualizarContaOrigjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel1))
                .addContainerGap(162, Short.MAX_VALUE))
        );
        origemjPanelLayout.setVerticalGroup(
            origemjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(origemjPanelLayout.createSequentialGroup()
                .addGroup(origemjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(atualizarContaOrigjButton)
                    .addGroup(origemjPanelLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(contaOrigemjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        origemjPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {atualizarContaOrigjButton, contaOrigemjComboBox});

        painelDestinojPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("painelDestinojPanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, resourceMap.getColor("painelDestinojPanel.border.titleColor"))); // NOI18N
        painelDestinojPanel.setToolTipText(resourceMap.getString("painelDestinojPanel.toolTipText")); // NOI18N
        painelDestinojPanel.setName("painelDestinojPanel"); // NOI18N
        painelDestinojPanel.setPreferredSize(new java.awt.Dimension(417, 243));

        contaDestjLabel.setText(resourceMap.getString("contaDestjLabel.text")); // NOI18N
        contaDestjLabel.setName("contaDestjLabel"); // NOI18N

        contaDestinojComboBox.setName("contaDestinojComboBox"); // NOI18N

        atualizarContaDestjButton.setIcon(resourceMap.getIcon("atualizarContaDestjButton.icon")); // NOI18N
        atualizarContaDestjButton.setName("atualizarContaDestjButton"); // NOI18N
        atualizarContaDestjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizarContaDestjButtonActionPerformed(evt);
            }
        });

        pessoajComboBox.setName("pessoajComboBox"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        atualizaPessoajButton.setIcon(resourceMap.getIcon("atualizaPessoajButton.icon")); // NOI18N
        atualizaPessoajButton.setName("atualizaPessoajButton"); // NOI18N
        atualizaPessoajButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizaPessoajButtonActionPerformed(evt);
            }
        });

        numDocjLabel.setText(resourceMap.getString("numDocjLabel.text")); // NOI18N
        numDocjLabel.setName("numDocjLabel"); // NOI18N

        tipoDocjLabel.setText(resourceMap.getString("tipoDocjLabel.text")); // NOI18N
        tipoDocjLabel.setName("tipoDocjLabel"); // NOI18N

        tipoDocjComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "Nota Fiscal", "Recibo", "Boleto", "Fatura", "Prolabore" }));
        tipoDocjComboBox.setName("tipoDocjComboBox"); // NOI18N

        tipoDocjButton.setIcon(resourceMap.getIcon("tipoDocjButton.icon")); // NOI18N
        tipoDocjButton.setName("tipoDocjButton"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        historicojTextField.setText(resourceMap.getString("historicojTextField.text")); // NOI18N
        historicojTextField.setName("historicojTextField"); // NOI18N

        numDocjTextField.setText(resourceMap.getString("numDocjTextField.text")); // NOI18N
        numDocjTextField.setName("numDocjTextField"); // NOI18N

        javax.swing.GroupLayout painelDestinojPanelLayout = new javax.swing.GroupLayout(painelDestinojPanel);
        painelDestinojPanel.setLayout(painelDestinojPanelLayout);
        painelDestinojPanelLayout.setHorizontalGroup(
            painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelDestinojPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(historicojTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
                    .addComponent(contaDestjLabel)
                    .addGroup(painelDestinojPanelLayout.createSequentialGroup()
                        .addComponent(contaDestinojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(atualizarContaDestjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel3)
                    .addComponent(numDocjLabel)
                    .addComponent(tipoDocjLabel)
                    .addComponent(jLabel6)
                    .addGroup(painelDestinojPanelLayout.createSequentialGroup()
                        .addGroup(painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(numDocjTextField, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tipoDocjComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pessoajComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 158, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tipoDocjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(atualizaPessoajButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        painelDestinojPanelLayout.setVerticalGroup(
            painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelDestinojPanelLayout.createSequentialGroup()
                .addGroup(painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(atualizarContaDestjButton)
                    .addGroup(painelDestinojPanelLayout.createSequentialGroup()
                        .addComponent(contaDestjLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(contaDestinojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(painelDestinojPanelLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pessoajComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(atualizaPessoajButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(numDocjLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(numDocjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelDestinojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelDestinojPanelLayout.createSequentialGroup()
                        .addComponent(tipoDocjLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tipoDocjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tipoDocjButton, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(historicojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        painelDestinojPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {atualizarContaDestjButton, contaDestinojComboBox});

        painelDestinojPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {atualizaPessoajButton, pessoajComboBox});

        painelDestinojPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {tipoDocjButton, tipoDocjComboBox});

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setName("jPanel3"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jFormattedTextField1.setText(resourceMap.getString("jFormattedTextField1.text")); // NOI18N
        jFormattedTextField1.setName("jFormattedTextField1"); // NOI18N

        dataLancjFormattedTextField.setFormatterFactory(Funcoes.setFormatoData());
        dataLancjFormattedTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        dataLancjFormattedTextField.setText(resourceMap.getString("dataLancjFormattedTextField.text")); // NOI18N
        dataLancjFormattedTextField.setName("dataLancjFormattedTextField"); // NOI18N

        valorfinaljFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        valorfinaljFormattedTextField.setName("valorfinaljFormattedTextField"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(162, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(20, 20, 20)
                        .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(valorfinaljFormattedTextField, 0, 0, Short.MAX_VALUE)
                    .addComponent(dataLancjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(dataLancjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(valorfinaljFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(12, 12, 12)
                        .addComponent(jLabel8)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setName("jPanel4"); // NOI18N

        sairjButton.setIcon(resourceMap.getIcon("sairjButton.icon")); // NOI18N
        sairjButton.setText(resourceMap.getString("sairjButton.text")); // NOI18N
        sairjButton.setName("sairjButton"); // NOI18N
        sairjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairjButtonActionPerformed(evt);
            }
        });

        executarjButton.setIcon(resourceMap.getIcon("executarjButton.icon")); // NOI18N
        executarjButton.setText(resourceMap.getString("executarjButton.text")); // NOI18N
        executarjButton.setName("executarjButton"); // NOI18N
        executarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                executarjButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(188, Short.MAX_VALUE)
                .addComponent(executarjButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(sairjButton)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sairjButton)
                    .addComponent(executarjButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel1.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, resourceMap.getColor("jPanel1.border.titleColor"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        comunidadejComboBox.setName("comunidadejComboBox"); // NOI18N

        atualizarComunidadejButton.setIcon(resourceMap.getIcon("atualizarComunidadejButton.icon")); // NOI18N
        atualizarComunidadejButton.setName("atualizarComunidadejButton"); // NOI18N
        atualizarComunidadejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizarComunidadejButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comunidadejComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(atualizarComunidadejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(atualizarComunidadejButton)
                    .addComponent(comunidadejComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {atualizarComunidadejButton, comunidadejComboBox});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(painelDestinojPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(origemjPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(origemjPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(painelDestinojPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    ClassConecta conexao;
    /**
     *
     */
    int operacao;
    /**
     *
     */
    String tipoRepasse = null;
    /**
     *
     */
    int valorCheque;
    /**
     *
     */
    public String operacaoDesc  = null;
    public int codFilial;
    


    private void sairjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairjButtonActionPerformed
        // TODO add your handling code here:

        this.dispose();
    }//GEN-LAST:event_sairjButtonActionPerformed

    private void executarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_executarjButtonActionPerformed
        try {
            // TODO add your handling code here:
            //Verificar campos obrigatorios
            if ((contaOrigemjComboBox.getSelectedIndex() == contaDestinojComboBox.getSelectedIndex()) && (operacao == 2)) {
                JOptionPane.showMessageDialog(null, "A conta de origem não pode ser igual a de destino.", "ATENÇÃO", JOptionPane.WARNING_MESSAGE);
                contaOrigemjComboBox.grabFocus();
                return;
            }
            if (valorfinaljFormattedTextField.getText().length() == 0) {
                JOptionPane.showMessageDialog(null, "O Campo <Valor do Lançamento:> é obrigatório.", "ATENÇÃO", JOptionPane.WARNING_MESSAGE);
                valorfinaljFormattedTextField.grabFocus();
                return;
            }
            if ((contaDestinojComboBox.getSelectedIndex() == -1) && (operacao == 2)) {
                JOptionPane.showMessageDialog(null, "O Campo <Conta Destino> é obrigatório.", "ATENÇÃO", JOptionPane.WARNING_MESSAGE);
                contaDestinojComboBox.grabFocus();
                return;
            }
            if (pessoajComboBox.getSelectedIndex() == -1) {
                JOptionPane.showMessageDialog(null, "O Campo <Responsável> é obrigatório.", "ATENÇÃO", JOptionPane.WARNING_MESSAGE);
                pessoajComboBox.grabFocus();
                return;
            }
            this.setAlwaysOnTop(false);
            ComboItem codConta = (ComboItem) contaDestinojComboBox.getSelectedItem();
            ComboItem codContaOrigem = (ComboItem) contaOrigemjComboBox.getSelectedItem();
            ComboItem codPessoa = (ComboItem) pessoajComboBox.getSelectedItem();
            ComboItem codComunidade = (ComboItem) comunidadejComboBox.getSelectedItem();

            switch (operacao) {
                case 0:
                    //Deposito
                    Integer numDoc = 0;
                    operacaoDesc = "Deposito";
                    Funcoes.setLancContabil(conexao, dataLancjFormattedTextField.getText(), codComunidade.getId(), codConta.getId(), numDoc, codPessoa.getId(), operacaoDesc, historicojTextField.getText(), Double.parseDouble(valorfinaljFormattedTextField.getValue().toString()),tipoDocjComboBox.getSelectedItem().toString());
                    break;

                    case 1:
                    //Saque
                    operacaoDesc = "Saque";
                    //setLancContabil(codConta.getId(), codCliente.getId(), historicojTextField.getText(), Double.parseDouble(valorTotalFinaljFormattedTextField.getValue().toString()) * -1);
                    Funcoes.setLancContabil(conexao, dataLancjFormattedTextField.getText(), codComunidade.getId(), codConta.getId(), Integer.parseInt(numDocjTextField.getText()), codPessoa.getId(), operacaoDesc, historicojTextField.getText(), Double.parseDouble(valorfinaljFormattedTextField.getValue().toString()) * -1, "Saque"  );
                    break;
                    case 2:
                    //Transferencia
                    operacaoDesc = "Transferencia";
                    String dePara = "de: " + codContaOrigem.toString() + " para: " + codConta.toString();
                    Funcoes.setLancContabil(conexao, dataLancjFormattedTextField.getText(), codComunidade.getId(), codContaOrigem.getId(), 1, codPessoa.getId(), "Saque", historicojTextField.getText()+ dePara , Double.parseDouble(valorfinaljFormattedTextField.getValue().toString()) * -1, "saque para tranferencia"  );
                    Funcoes.setLancContabil(conexao, dataLancjFormattedTextField.getText(), codComunidade.getId(), codConta.getId(), 0, codPessoa.getId(), "Depósito", historicojTextField.getText()+ dePara , Double.parseDouble(valorfinaljFormattedTextField.getValue().toString()),"deposito para transferencia"   );
                    break;



            }
            ClassConecta.con.commit();

            JOptionPane.showMessageDialog(null, operacaoDesc + " realizado(a) com sucesso!", "SUCESSO!", JOptionPane.INFORMATION_MESSAGE);
            sairjButtonActionPerformed(null);


        } catch (SQLException ex) {
            Logger.getLogger(jFOperacao.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParseException ex) {
            Logger.getLogger(jFOperacao.class.getName()).log(Level.SEVERE, null, ex);
        }
            
    }//GEN-LAST:event_executarjButtonActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        
        //Saque
        setLocationRelativeTo(null);
        if (operacao == 1){
            TitledBorder tituloPainel = new TitledBorder("Saque");
            Font fontPainel = new Font("Tahoma", 0, 11);
            Color corTituloPainel = new Color(0, 0, 153);
            painelDestinojPanel.setBorder(tituloPainel);
            tituloPainel.setTitleFont(fontPainel);
            tituloPainel.setTitleColor(corTituloPainel);
            contaDestjLabel.setText("Conta");
            
        }

        //Se a operação for Depósito ou Transferência irá ocultar os campos
        if ((operacao == 0) || (operacao == 2) ){
            numDocjTextField.setVisible(false);
            tipoDocjComboBox.setVisible(false);
            numDocjLabel.setVisible(false);
            tipoDocjLabel.setVisible(false);
            tipoDocjButton.setVisible(false);
        }
        
        if (operacao != 2) {
                //Transferencia
                origemjPanel.setVisible(false);

            } else {
                origemjPanel.setVisible(true);
        }
        try {
            dataLancjFormattedTextField.setText(Funcoes.getNowBR());
        } catch (ParseException ex) {
            Logger.getLogger(jFOperacao.class.getName()).log(Level.SEVERE, null, ex);
        }
        atualizarComunidadejButtonActionPerformed(null);
        atualizarContaOrigjButtonActionPerformed(null);
        atualizarContaDestjButtonActionPerformed(null);
        atualizaPessoajButtonActionPerformed(null);


    }//GEN-LAST:event_formWindowOpened

    private void atualizarComunidadejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizarComunidadejButtonActionPerformed
        // TODO add your handling code here:
            try {
            Comunidade oComunidade = new Comunidade();
            ResultSet rs = null;
            rs = oComunidade.getConsultar();
            comunidadejComboBox.removeAllItems();
            while (rs.next()) {
                comunidadejComboBox.addItem(new ComboItem(rs.getInt(1), rs.getString(2)));
            }
            comunidadejComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFCaixa.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizarComunidadejButtonActionPerformed

    private void atualizarContaOrigjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizarContaOrigjButtonActionPerformed
        // TODO add your handling code here:
            try {
            Contas oConta = new Contas();
            ResultSet rs = null;
            rs = oConta.getConsultarContas();
            contaOrigemjComboBox.removeAllItems();
            while (rs.next()) {
                contaOrigemjComboBox.addItem(new ComboItem(rs.getInt("codConta"), rs.getString("banco")));
            }
            contaOrigemjComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFCaixa.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizarContaOrigjButtonActionPerformed

    private void atualizarContaDestjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizarContaDestjButtonActionPerformed
        // TODO add your handling code here:
            try {
            Contas oConta = new Contas();
            ResultSet rs = null;
            rs = oConta.getConsultarContas();
            contaDestinojComboBox.removeAllItems();
            while (rs.next()) {
                contaDestinojComboBox.addItem(new ComboItem(rs.getInt("codConta"), rs.getString("banco")));
            }
            contaDestinojComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFCaixa.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizarContaDestjButtonActionPerformed

    private void atualizaPessoajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizaPessoajButtonActionPerformed
        // TODO add your handling code here:
            try {
            Pessoas oPessoa = new Pessoas();
            ResultSet rs = null;
            rs = oPessoa.getConsultarPessoa();
            pessoajComboBox.removeAllItems();
            while (rs.next()) {
                pessoajComboBox.addItem(new ComboItem(rs.getInt("codPessoa"), rs.getString("pessoa")));
            }
            pessoajComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(jFCaixa.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizaPessoajButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jFOperacao().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton atualizaPessoajButton;
    private javax.swing.JButton atualizarComunidadejButton;
    private javax.swing.JButton atualizarContaDestjButton;
    private javax.swing.JButton atualizarContaOrigjButton;
    private javax.swing.JComboBox comunidadejComboBox;
    private javax.swing.JComboBox contaDestinojComboBox;
    private javax.swing.JLabel contaDestjLabel;
    private javax.swing.JComboBox contaOrigemjComboBox;
    private javax.swing.JFormattedTextField dataLancjFormattedTextField;
    private javax.swing.JButton executarjButton;
    private javax.swing.JTextField historicojTextField;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel numDocjLabel;
    private javax.swing.JTextField numDocjTextField;
    private javax.swing.JPanel origemjPanel;
    private javax.swing.JPanel painelDestinojPanel;
    private javax.swing.JComboBox pessoajComboBox;
    private javax.swing.JButton sairjButton;
    private javax.swing.JButton tipoDocjButton;
    private javax.swing.JComboBox tipoDocjComboBox;
    private javax.swing.JLabel tipoDocjLabel;
    private javax.swing.JFormattedTextField valorfinaljFormattedTextField;
    // End of variables declaration//GEN-END:variables

}
